//
//  TimerHandler.h
//  HSGProject
//
//  Created by 清正 on 16/8/30.
//  Copyright © 2016年 HSG. All rights reserved.
//

#import <Foundation/Foundation.h>

///定时器(Timer)
@interface TimerHandler : NSObject

/**
 *  开启定时器[销毁定时器调用:dispatch_source_cancel(timer)]
 *
 *  @param time  多久执行一次
 *  @param block 返回定时器对象;
)
 */
+ (dispatch_source_t)openTimerEveryTime:(NSTimeInterval)time eventHandler:(void (^)(dispatch_source_t timer))block;

/**
 *  倒计时
 *
 *  @param second  倒多久
 *  @param block 返回定时器对象和剩余的时间
 */
+ (dispatch_source_t)countdownSecond:(NSInteger)second eventHandler:(void (^)(dispatch_source_t timer, NSInteger surplusTime))block;
/**
 *  延迟执行
 *
 *  @param time  延迟时间
 *  @param newBlock nil
 */
+ (void)performAfterDelay:(NSTimeInterval)time handler:(void (^)(void))newBlock;

@end
